//
//  FirstMainViewController.m
//  ShangPiBao
//
//  Created by chirui on 2017/10/13.
//  Copyright © 2017年 Shui. All rights reserved.
//

#import "FirstMainViewController.h"
#import "MainDetailsViewController.h" //15
#import "MainTableViewCell.h"
#import "CompanyMainDetailsVController.h" //公司详情
#import "MainTenDetailsViewController.h"
#import "MianEightViewController.h"
#import "CompanyListViewController.h"
#import "ImageTextButton.h"


@interface FirstMainViewController ()<UITableViewDelegate,UITableViewDataSource,SDCycleScrollViewDelegate,UITextFieldDelegate>{
    
    UITableView * _tableView;
    UIView * searchView;
    UIButton * searchBtn;
    UITextField * searchText;
    
    NSDictionary * dataDic;
    
    NSArray * dataArray;
}

@property (nonatomic,strong) ImageTextButton * areButton;

@end

@implementation FirstMainViewController


//nav
- (UIView *)navBarView {
    if (!_navBarView) {
        _navBarView = [[UIView alloc] init];
        _navBarView.backgroundColor = [UIColor blackColor];
        _navBarView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64);
    }
    return _navBarView;
}
//nav
- (void)setupNavigationBar {
    
    // 导航栏背景view
    _navigationBackView = [[UIView alloc] init];
    _navigationBackView.frame = CGRectMake(0, 0, WIDTH, 64);
    
    if (searchView==nil) {
        
        
        self.areButton = [[ImageTextButton alloc] initWithFrame:CGRectMake(10, 16, 60,40 )
                                                          image:[UIImage imageNamed:@"icon_nav_drop_down"]
                                                          title:@"陕西"];
        self.areButton.buttonTitleWithImageAlignment = UIButtonTitleWithImageAlignmentRight;
        [_navigationBackView addSubview:self.areButton];
        
        
         searchBtn =[UIButton buttonWithType:UIButtonTypeSystem];
        [searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
        searchBtn.frame = CGRectMake(WIDTH -60, 17, 40, 40);
        [searchBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        searchBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [searchBtn addTarget:self action:@selector(searchClick:) forControlEvents:UIControlEventTouchUpInside];
        [_navigationBackView addSubview:searchBtn];
        
        searchView =[[UIView alloc]initWithFrame:CGRectMake(75, 20, WIDTH - 150, 30)];
        searchView.layer.cornerRadius = 15.f;
        searchView.layer.masksToBounds = YES;
        
        UIImageView * searchImage =[[UIImageView alloc]initWithFrame:CGRectMake(10, 0, 30, 30)];
        searchImage.image =[UIImage imageNamed:@"icon_nav_search"];
        [searchView addSubview:searchImage];
        searchView.backgroundColor = ColorA(255, 255, 255, 0.7);
        
        searchText =[[UITextField alloc]initWithFrame:CGRectMake(40, 0, CGRectGetWidth(searchView.frame)-40, 30)];
        searchText.font =[UIFont systemFontOfSize:14];
        searchText.delegate = self;
        searchText.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入产品或者公司名称" attributes:@{NSForegroundColorAttributeName: [UIColor grayColor]}];
        [searchView addSubview:searchText];
       
        
        [self.navigationBackView addSubview:searchView];
    }else {
        [searchBtn removeFromSuperview];
        [searchView removeFromSuperview];
    }
    
    
    [self.view addSubview:_navigationBackView];
}

//nav
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    
    CGFloat offset_Y = scrollView.contentOffset.y;
    CGFloat alpha = (offset_Y)/300.0f;
    self.navigationBackView.backgroundColor = [NavBackColor colorWithAlphaComponent:alpha];
    if (alpha> 0) {
        
        if (searchView==nil) {
            searchView =[[UIView alloc]initWithFrame:CGRectMake(50, 20, WIDTH - 150, 30)];
            searchView.layer.cornerRadius = 15.f;
            searchView.layer.masksToBounds = YES;
            
            self.areButton = [[ImageTextButton alloc] initWithFrame:CGRectMake(10, 16, 60,40 )
                                                              image:[UIImage imageNamed:@"icon_nav_drop_down"]
                                                              title:@"陕西"];
            self.areButton.buttonTitleWithImageAlignment = UIButtonTitleWithImageAlignmentRight;
            [_navigationBackView addSubview:self.areButton];
            
            searchBtn =[UIButton buttonWithType:UIButtonTypeSystem];
            searchBtn.frame = CGRectMake(WIDTH -60, 17, 40, 40);
            [searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
            [searchBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [searchBtn addTarget:self action:@selector(searchClick:) forControlEvents:UIControlEventTouchUpInside];
            searchBtn.titleLabel.font = [UIFont systemFontOfSize:16];
            [_navigationBackView addSubview:searchBtn];
            
            UIImageView * searchImage =[[UIImageView alloc]initWithFrame:CGRectMake(10, 0, 30, 30)];
            searchImage.image =[UIImage imageNamed:@"icon_nav_search"];
            [searchView addSubview:searchImage];
            searchView.backgroundColor = ColorA(255, 255, 255, 0.7);
            
            searchText =[[UITextField alloc]initWithFrame:CGRectMake(10, 0, CGRectGetWidth(searchView.frame)-40, 30)];
            searchText.font =[UIFont systemFontOfSize:14];
            searchText.delegate = self;
          
            [searchView addSubview:searchText];
            
            [self.navigationBackView addSubview:searchView];
            [self.navigationBackView addSubview:searchBtn];
        }
        
    }
}

-(void)textFieldDidBeginEditing:(UITextField *)textField {
    
}

-(void)searchClick:(UIButton *)btn{
    
    [searchText resignFirstResponder];
    if (searchText.text.length<=0||searchText.text==nil) {
        
        SHuiMBhudTextTimeStr(@"请输入关键字搜索");
        
        return;
    }
    CompanyListViewController * lists =[[CompanyListViewController alloc]init];
     lists.classId = @"0";
     lists.bannerIdStr = @"0,0s";
    lists.searchStr = searchText.text;
    lists.titleStr = @"搜索列表";
    lists.isSearch  = @"search";
    lists.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:lists animated:YES];
}


-(void)viewWillDisappear:(BOOL)animated {
    
    
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

-(void)viewWillAppear:(BOOL)animated {
    
    
    [self.navBarView removeFromSuperview];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    
   
    
}

- (BOOL)prefersStatusBarHidden {
    return YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
   
    TitleView(@"首页");
    self.view.backgroundColor =[UIColor whiteColor];
    [self creatTableView];
    
    [self setupNavigationBar];
    
    [self getBannerDataListRequest];
}

-(void)creatTableView{

    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-48) style:UITableViewStyleGrouped];
    _tableView.dataSource =self;
    _tableView.delegate =self;
    [self.view addSubview:_tableView];
     _tableView.backgroundColor =[UIColor whiteColor];
    [_tableView registerNib:[UINib nibWithNibName:[MainTableViewCell reuseIdentifier] bundle:nil] forCellReuseIdentifier:[MainTableViewCell reuseIdentifier]];
    MJRefreshNormalHeader * header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        
       [self getBannerDataListRequest];
        
    }];
    _tableView.mj_header =header;
    
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    
    if ([dataDic[@"position4"] isKindOfClass:[NSArray class]]) {
        
        dataArray = dataDic[@"position4"];
        
        return dataArray.count;
    }else{
         return 0;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    return 100;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

     float brandHeight = (WIDTH -40)/3 * 1.35;
     float fourHeight = (WIDTH -50)/4 * 1.4;
    
    return 430+ brandHeight + fourHeight+230;

}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    return 0.01;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    NSDictionary * dic = dataArray[indexPath.row];
    MainTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[MainTableViewCell reuseIdentifier] forIndexPath:indexPath];
    cell.details.frame = CGRectMake(100, 38, WIDTH -110, 20);
    [cell.imageIcon sd_setImageWithURL:ImageUrl(dic[@"apicture"]) placeholderImage:ImageName(@"img_home_newest")];
    cell.details.text = dic[@"acontent"];
    cell.titleLabel.text = dic[@"atitle"];
    cell.details.numberOfLines = 3;
    [cell.details sizeToFit];
    
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSDictionary * dic = dataArray[indexPath.row];
    if ([dic[@"aurl"] isEqualToString:@"0"]) {
        
    }else{
        CompanyMainDetailsVController * company =[[CompanyMainDetailsVController alloc]init];
        company.companyId = dic[@"aurl"];
        company.companyNameStr = dic[@"atitle"];
        company.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:company animated:YES];
    }

}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
 
    float brandWidth = (WIDTH -40)/3;
    float brandHeight = (WIDTH -40)/3 * 1.35;
    
    float fourWidth = (WIDTH -50)/4;
    float fourHeight = (WIDTH -50)/4 * 1.4;

    UIView * heardView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 430+ brandHeight + fourHeight+270)];
    heardView.backgroundColor =[UIColor whiteColor];
   
    NSMutableArray * bannerImageArray = @[].mutableCopy;
    NSMutableArray * bannerIdArray = @[].mutableCopy;
    
    if ([dataDic[@"position1"] isKindOfClass:[NSArray class]]) {
        
        if (bannerImageArray.count>0) {
            [bannerIdArray removeAllObjects];
            [bannerImageArray removeAllObjects];
        }
        NSArray * arry = dataDic[@"position1"];
        for (NSDictionary * dic in arry) {
            
            [bannerImageArray addObject:dic[@"apicture"]];
            [bannerIdArray addObject:dic];
        }
    }

    SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0,0, WIDTH, 160) delegate:self placeholderImage:[UIImage imageNamed:@""]];
    cycleScrollView.backgroundColor =Color(229, 229, 229);
    cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
    cycleScrollView.currentPageDotColor = [UIColor whiteColor];
    cycleScrollView.autoScrollTimeInterval = 3.5;
    if (bannerImageArray.count==1) {
        cycleScrollView.autoScroll = NO;
    }
    [heardView addSubview:cycleScrollView];
    cycleScrollView.imageURLStringsGroup = bannerImageArray;
    cycleScrollView.clickItemOperationBlock = ^(NSInteger index) {
        NSDictionary * dic = bannerIdArray[index];
        if ([dic[@"aurl"] isEqualToString:@"0"]) {
            
        }else{
            CompanyMainDetailsVController * company =[[CompanyMainDetailsVController alloc]init];
            company.companyId = dic[@"aurl"];
            company.companyNameStr = dic[@"atitle"];
            company.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:company animated:YES];
        }
    };

    CGFloat imageWide = 60;
    CGFloat gapWide = (WIDTH - 60*4)/5;
    
    NSArray * imageArray = @[@"icon_home_hardware",@"icon_home_architecture",@"icon_home_hotel",@"icon_home_parts",@"icon_home_office",@"icon_home_forestry",@"icon_home_costume",@"icon_home_logistics"];
    NSArray * titleArray = @[@"五金机电",@"建筑材料",@"酒店用品",@"汽配汽用",@"文体办公",@"农林牧渔 ",@"服装鞋包",@"物流货运"];
    
    UIView * classView =[[UIView alloc]initWithFrame:CGRectMake(0, 160, WIDTH, 180)];
    classView.backgroundColor = [UIColor whiteColor];
    [heardView addSubview:classView];
    
    for (int i = 0; i < 8; i++) {
        
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        
        btn.frame = CGRectMake(gapWide+gapWide*(i%4)+imageWide*(i % 4), 10+10 *(i/4)+(imageWide+15)*(i/4) , imageWide, imageWide);
        btn.tag = 100 + i;
        btn.layer.cornerRadius = 30.f;
        btn.layer.masksToBounds = YES;
        [btn setImage:[UIImage imageNamed:imageArray[i]] forState:UIControlStateNormal];
        btn.backgroundColor =[UIColor whiteColor];
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [classView addSubview:btn];
        
        UILabel *label = [[UILabel alloc]init];
        label.center = CGPointMake(btn.center.x, btn.center.y + imageWide / 2.f +10);
        label.bounds = CGRectMake(0, 0, 100, 13);
        label.font = [UIFont systemFontOfSize:13];
        label.textColor = [UIColor blackColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.text =titleArray[i];
        [classView addSubview:label];
    }
    
    UIView * lineView =[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(classView.frame), WIDTH, 10)];
    lineView.backgroundColor =[UIColor groupTableViewBackgroundColor];
    [heardView addSubview:lineView];
    
    
    
    UIView * goodsClassView;
     UIView * fourView;
    NSArray * sevenDataArray;
    
    if ([dataDic[@"position2"] isKindOfClass:[NSArray class]]) {
        
        sevenDataArray = dataDic[@"position2"];
    }
    if (sevenDataArray.count==7) {
        
        for (int g = 0; g<3; g++) {
            
            NSDictionary * dic = sevenDataArray[g];
            goodsClassView = [self creatBtnViewFrame:CGRectMake(10+brandWidth*g+10*g, CGRectGetMaxY(lineView.frame)+10, brandWidth, brandHeight) andBorderColor:[UIColor clearColor] onView:heardView];
            goodsClassView.layer.borderWidth = 0.5;
            [goodsClassView tapAction:^{
                
                if ([dic[@"aurl"] isEqualToString:@"0"]) {
                    
                }else{
                CompanyMainDetailsVController * company =[[CompanyMainDetailsVController alloc]init];
                company.companyId = dic[@"aurl"];
                company.companyNameStr = dic[@"atitle"];
                company.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:company animated:YES];
                }
             
            }];
            goodsClassView.layer.borderColor = RGB(0xe5e5e5).CGColor;
            
            
            [self creatLaberFrame:CGRectMake(0,10, brandWidth, 20) andFontOfSize:15 andTextColor:RGB(0x4c4c4c) andText:dic[@"atitle"] andAlignment:NSTextAlignmentCenter onView:goodsClassView];
            
            [self creatLaberFrame:CGRectMake(0,30, brandWidth, 20) andFontOfSize:13 andTextColor:[UIColor orangeColor] andText:dic[@"acontent"] andAlignment:NSTextAlignmentCenter onView:goodsClassView];
            
            UIImageView * heardImage =[[UIImageView alloc]initWithFrame:CGRectMake(8, 60,brandWidth-16 ,brandHeight -65)];
            heardImage.backgroundColor = [UIColor whiteColor];
            [heardImage sd_setImageWithURL:ImageUrl(dic[@"apicture"]) placeholderImage:ImageName(@"img_home_newest")];
            [goodsClassView addSubview:heardImage];
        }
        
       
        for (int g = 0; g<4; g++) {
            
            NSDictionary * dic = sevenDataArray[g+3];
            fourView = [self creatBtnViewFrame:CGRectMake(10+fourWidth*g+10*g, CGRectGetMaxY(goodsClassView.frame)+10, fourWidth, fourHeight) andBorderColor:[UIColor clearColor] onView:heardView];
            fourView.layer.borderWidth = 0.5;
            [fourView tapAction:^{
                NSString * enter = USER_DEFAULTGet(@"enter");
                if ([enter isEqualToString:@"ok"]) {
                    
                    if ([dic[@"aurl"] isEqualToString:@"0"]) {
                        
                    }else{
                        CompanyMainDetailsVController * company =[[CompanyMainDetailsVController alloc]init];
                        company.companyId = dic[@"aurl"];
                        company.companyNameStr = dic[@"atitle"];
                        company.hidesBottomBarWhenPushed = YES;
                        [self.navigationController pushViewController:company animated:YES];
                    }

                }else{
                    LogingViewController * loging =[[LogingViewController alloc]init];
                    loging.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:loging animated:YES];
                }
            }];
            fourView.layer.borderColor = RGB(0xe5e5e5).CGColor;
            
            [self creatLaberFrame:CGRectMake(0,8, fourWidth, 18) andFontOfSize:14 andTextColor:RGB(0x4c4c4c) andText:dic[@"atitle"] andAlignment:NSTextAlignmentCenter onView:fourView];
            
            [self creatLaberFrame:CGRectMake(0,26, fourWidth, 15) andFontOfSize:12 andTextColor:[UIColor orangeColor] andText:dic[@"acontent"] andAlignment:NSTextAlignmentCenter onView:fourView];
            
            UIImageView * heardImage =[[UIImageView alloc]initWithFrame:CGRectMake(5, 46,fourWidth-10 ,fourHeight -49)];
            heardImage.backgroundColor = [UIColor whiteColor];
           [heardImage sd_setImageWithURL:ImageUrl(dic[@"apicture"]) placeholderImage:ImageName(@"img_home_newest")];
            [fourView addSubview:heardImage];
        }

        
    }
                          
   
    UIView * lineSecondView =[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(fourView.frame)+10, WIDTH, 10)];
    lineSecondView.backgroundColor =[UIColor groupTableViewBackgroundColor];
    [heardView addSubview:lineSecondView];
    
    UIView * sixView;
    NSArray * sixDataArray;
    if ([dataDic[@"position2"] isKindOfClass:[NSArray class]]) {
        
        sixDataArray = dataDic[@"position3"];
    }
    if (sixDataArray.count==6) {
    
    for (int i = 0; i<6; i++) {

        NSDictionary * dic = sixDataArray[i];
        sixView = [self creatBtnViewFrame:CGRectMake(0*(i%2)+(WIDTH)/2*(i%2), CGRectGetMaxY(lineSecondView.frame)+ 70 *(i/2), (WIDTH)/2, 70) andBorderColor:[UIColor clearColor] onView:heardView];
        sixView.layer.borderWidth = 0.3;
        [sixView tapAction:^{
           
            if ([dic[@"aurl"] isEqualToString:@"0"]) {
                
            }else{
                CompanyMainDetailsVController * company =[[CompanyMainDetailsVController alloc]init];
                company.companyId = dic[@"aurl"];
                company.companyNameStr = @"";
                company.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:company animated:YES];
            }

        }];
        sixView.layer.borderColor = RGB(0xe5e5e5).CGColor;
        
        [self creatLaberFrame:CGRectMake(10,15, (WIDTH)/2 - 90 - 15, 20) andFontOfSize:15 andTextColor:RGB(0x4c4c4c) andText:dic[@"atitle"] andAlignment:NSTextAlignmentLeft onView:sixView];
        
        [self creatLaberFrame:CGRectMake(10,40,(WIDTH)/2 - 90 - 15, 20) andFontOfSize:13 andTextColor:RGB(0x4c4c4c) andText:dic[@"acontent"]  andAlignment:NSTextAlignmentLeft onView:sixView];
        
        UIImageView * heardImage =[[UIImageView alloc]initWithFrame:CGRectMake((WIDTH)/2 - 70, 5,65 ,60)];
        heardImage.backgroundColor = [UIColor whiteColor];
       [heardImage sd_setImageWithURL:ImageUrl(dic[@"apicture"]) placeholderImage:ImageName(@"img_home_newest")];
        [sixView addSubview:heardImage];
      }
    }
    UIView * linetitleView =[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(sixView.frame), WIDTH, 10)];
    linetitleView.backgroundColor =[UIColor groupTableViewBackgroundColor];
    [heardView addSubview:linetitleView];
    
    UILabel * titleLabel =[[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(linetitleView.frame)+15, WIDTH - 20, 20)];
    titleLabel.text = @"推荐商户";
    [heardView addSubview:titleLabel];
    
    return heardView;
}

-(void)btnClick:(UIButton *)btn{

    if (btn.tag ==100) {
        
        MainDetailsViewController * main =[[MainDetailsViewController alloc]init];
        main.hidesBottomBarWhenPushed = YES;
        main.type = @"五金机电";
        main.classIdStr = @"0,8";
        [self.navigationController pushViewController:main animated:YES];
    }else if (btn.tag == 101){
    
        MainTenDetailsViewController * main =[[MainTenDetailsViewController alloc]init];
        main.type = @"建筑材料";
        main.classIdStr = @"0,2";
        main.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:main animated:YES];
    }else if (btn.tag == 102){
        MianEightViewController * main =[[MianEightViewController alloc]init];
        main.type = @"酒店用品";
        main.classIdStr = @"0,6";
        main.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:main animated:YES];
    }else if (btn.tag == 103){
        MainDetailsViewController * main =[[MainDetailsViewController alloc]init];
        main.hidesBottomBarWhenPushed = YES;
        main.type = @"汽配汽用";
        main.classIdStr = @"0,7";
        [self.navigationController pushViewController:main animated:YES];
    }else if (btn.tag == 104){
        MianEightViewController * main =[[MianEightViewController alloc]init];
        main.type = @"文体办公";
        main.classIdStr = @"0,5";
        main.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:main animated:YES];
    }else if (btn.tag == 105){
        MianEightViewController * main =[[MianEightViewController alloc]init];
        main.type = @"农林牧渔";
        main.classIdStr = @"0,4";
        main.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:main animated:YES];
    }else if (btn.tag == 106){
        MianEightViewController * main =[[MianEightViewController alloc]init];
        main.type = @"服装鞋包";
        main.classIdStr = @"0,3";
        main.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:main animated:YES];
    }else if (btn.tag == 107){
        MianEightViewController * main =[[MianEightViewController alloc]init];
        main.type = @"物流货运";
        main.classIdStr = @"0,1";
        main.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:main animated:YES];
    }
}

-(UIView *)creatBtnViewFrame:(CGRect)rec andBorderColor:(UIColor *)col onView:(UIView *)view {
    
    UIView * btnView =[[UIView alloc]init];
    btnView.frame = rec;
    btnView.layer.borderWidth = 0.7f;
    btnView.layer.borderColor = col.CGColor;
    btnView.backgroundColor =[UIColor whiteColor];
    //    btnView.layer.cornerRadius = 5.f;
    //    btnView.layer.masksToBounds =YES;
    [view addSubview:btnView];
    
    return btnView;
}
-(void)creatLaberFrame:(CGRect)rec andFontOfSize:(float)size andTextColor:(UIColor*)col andText:(NSString *)text andAlignment:(NSTextAlignment )ment onView:(UIView *)view {
    
    UILabel * label =[[UILabel alloc]initWithFrame:rec];
    label.font = [UIFont systemFontOfSize:size];
    label.textColor =col;
    label.textAlignment = ment;
    label.text = text;
    [view addSubview:label];
    
}


-(void)getBannerDataListRequest{

    NSString * md5ver = [SHJudgeTools md532BitLower:[NSString
                                                     stringWithFormat:@"%@api.shangpibao.com",USER_DEFAULTGet(@"phone")]];
    NSString * parametersStr = [NSString stringWithFormat:@"%@%@?uphone=%@&ver=%@&aclass=0,0&page=1",address_url,new_allNews_api,USER_DEFAULTGet(@"phone"),md5ver];

    [PostNetWorking netWorkingStr:parametersStr  Success:^(id responseObject) {
        SHuiMBHidleYes;
        if ([responseObject[@"err"] intValue]==0) {
            
            dataDic = responseObject;
  
        } else {
            
            SHuiMBhudTextTimeStr(EorrMessageStr);
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            
            [_tableView.mj_header endRefreshing];
            [_tableView reloadData];
            
        });

    } failed:^(NSError *error) {
        
        SHuiMBHidleYes;
        SHuiMBhudTextTimeStr(@"请检查您的网络!");
    }];



}

@end
